package com.prs.crm.dao.doc.impl;


import java.sql.SQLException;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.doc.DeptDocDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.crm.Liaison;
import com.prs.crm.domain.doc.DeptDoc;
import com.prs.crm.domain.doc.DeptDocType;

public class DeptDocDaoImp extends BaseDaoImpl<DeptDoc> implements DeptDocDao {

	@SuppressWarnings("unchecked")
	@Override
	public Collection<DeptDoc> listDeptDocByType(final DeptDocType deptDocType) {
		// TODO Auto-generated method stub
		return (Collection<DeptDoc>) this.getHibernateTemplate().execute(new HibernateCallback(){

			@Override
			public Object doInHibernate(Session arg0)
					throws HibernateException, SQLException {
				// TODO Auto-generated method stub
				Criteria criteria = arg0.createCriteria(DeptDoc.class);
				criteria.add(Restrictions.eq("type", deptDocType));
				return criteria.list();
			}});
	}

	@Override
	public Collection<DeptDoc> getDeptDocByIds(Integer[] ids) {
		// TODO Auto-generated method stub
		Criteria criteria = this.getSession().createCriteria(DeptDoc.class);
		criteria.add(Restrictions.in("id", ids));
		return criteria.list();
	}



}
